<?php
class Backend_Designer_Sub_Viewframe extends Backend_Designer_Sub
{
	public function indexAction()
	{
		if(!$this->_session->keyExists('loaded') || !$this->_session->get('loaded')){
			Response::put('');
			exit;
		}
		$cfg = Application::getConfig();
		$res = Resource::getInstance();
		$res->addJS('/js/app/system/designer/viewframe/main.js');
		$res->addJS('/js/app/system/designer/lang/'.$cfg['language'].'.js');
	
		$project = $this->_getProject();
		
		$res->addInlineJs($project->getCode());
		
		$names = $project->getRootPanels();
		
		
		$initCode = 'Ext.onReady(function(){';
		
		if(!empty($names))
			$initCode.='frApp.viewFrame.add('.implode(',', $names).');';
		
		$initCode.='});';
		
		$res->addInlineJs($initCode);

		$tpl = new Template();
		$tpl->lang = $cfg['language'];
		$tpl->development = $cfg['development'];
		$tpl->resource = $res;
		
		Response::put($tpl->render(Application::getTemplatesPath().'designer/viewframe.php'));
	}
}